package Operator;

import Book.Book;
import Book.BookList;

import java.util.Scanner;

public class FindOperator implements IOPerator{
    @Override
    public void work(BookList bookList) {
        System.out.println("查找图书");
        System.out.print("请输出你要查找的图书名:>");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        int bookcount = bookList.getListsize();
        for (int i = 0; i < bookcount; i++) {
            Book book = bookList.get_book(i);
            if(book.getName().equals(name)){
                System.out.println("找到了你要的书");
                System.out.println(book);
                return;
            }
        }
        System.out.println("很抱歉!书架上没有你要的图书");
    }
}
